package com.hd.system.user.controller;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hd.base.controller.BaseController;
import com.hd.base.service.BaseService;
import com.hd.system.user.model.HdUser;
import com.hd.system.user.service.HdUserService;
import com.hd.util.ResultCommonUtils;


@Controller
@RequestMapping("/hdUser")
public class HdUserController extends BaseController<HdUser> {

	@Autowired
	private HdUserService hdUserService;
	
	
	@RequestMapping(value = "/queryByName", 
			method = RequestMethod.GET, 
			produces = MediaType.APPLICATION_JSON_VALUE + ";Charset=UTF-8")
	@ResponseBody
	public ResultCommonUtils queryUserList(HttpServletRequest request, @RequestParam("loginName") String loginName) {
		ResultCommonUtils resultCommon = new ResultCommonUtils();
		try {
			HdUser user = new HdUser();
			user.setId("1234");
			user.setLoginName("张三");
			user.setPassword("abcdefgh");
			user.setPasswordMd5("123456");
			user.setStatus(true);
			user.setCreateUserId("111111");
			user.setCreateUser("张三");
			user.setCreateTime(new Date());

			hdUserService.save(user);
			System.out.println("插入用户信息" + user.getRealName());

		} catch (Exception e) {

		}

		return resultCommon;
	}


	@Override
	public BaseService<HdUser> getBaseService() {
		// TODO Auto-generated method stub
		return hdUserService;
	}
}
